<?php

namespace app\model;

use think\Model;

class Resource extends Model
{
    // 定义资源表名
    protected $table = 'resources';

    // 定义资源类型常量
    const TYPE_QUESTION_BANK = 'question_bank';
    const TYPE_VIDEO = 'video';
    const TYPE_DOCUMENT = 'document';
    const TYPE_LINK = 'link';

    // 定义资源所属项目
    public function project()
    {
        return $this->belongsTo(ProjectModel::class);
    }

    // 定义资源上传者
    public function uploader()
    {
        return $this->belongsTo(UserModel::class, 'uploader_id');
    }
}